<!-- ---------------------------------------------------- -->

<script type="text/javascript">
    function f_login(){
        document.frm_login.action = '<?php echo url_for('home_login/index') ?>';
        document.frm_login.submit();
    }

</script>


<form method="post" name="frm_login" action="" id="frm_login">

    <div  style="float: right;margin-top: 3px;">
        <div style="float: left;margin-right: 5px;"><input class="input-user" tabindex="1" type="text" name="txt_usuario" id="txt_usuario" value="usuario" onfocus="if(this.value == 'usuario' ){this.value='';}" onblur="if(this.value == '') {this.value = 'usuario';}" /></div>
        <div style="float: left;margin-right: 5px;"><input tabindex="2" type="password"  name="txt_password" id="txt_password" /></div>
        <div style="float: left;">
                         <?php if($token=="open"): ?>
                                     <a class="btn btn_sing_in_aceptor" tabindex="3" href="javascript:void(0);" id="asociar-account"><span class="text-btn">Entrar</span> </a>
                               <?php else: ?>
                                     <a class="btn btn_sing_in_aceptor" tabindex="3"  href="javascript:void(0);" onclick="f_login();"><span class="text-btn">Entrar</span> </a>
                         <?php endif; ?>
         </div>
     </div>
 </form>

<!-- ---------------------------------------------------- -->



 <?php if($token=="open"): ?>  

<div title="Asociar Cuenta" id="div-asociar-cuenta">
    <div style="margin-left: 15px;">
          <div style="margin: 10px;margin-left: 0px;">  </div>

          <div style="width: 250px;height: 60px;border: 1px solid red;margin-left: 5px;text-align: center;padding-top: 35px;">
            Pracil  => Aceptor
          </div>
               <div style="margin: 10px;margin-left: 0px;"> Cuenta a Asociar :  <?php echo $email  ?> </div>
           <div id="div-load-ajax" style="display: none;margin: 10px;margin-left: 0px;">
               <div id="text-load-ajax" style="color: blue;text-align:center;width: 230px;">
                   Verificando cuenta ...
               </div>
               <div style="width: 230px;"><?php echo image_tag('ajax-loader.gif') ?></div>
           </div>
           <div id="div-botonera" style="margin: 10px;margin-left: 0px;"> <a href="javascript:void(0)" id="btn-asociar-cuenta">Asociar</a>&nbsp;&nbsp;&nbsp;<a  href="javascript:void(0)" id="btn-cancelar">Cancelar</a></div>
      </div>
<input type="hidden" name="token_practil" id="token_practil" />
<input type="hidden" name="name_practil" id="name_practil" />
<input type="hidden" name="last_name" id="last_name" />
<input type="hidden" name="email" id="email" />
<input type="hidden" name="email_associate" id="email_associate" value="<?php echo $email  ?>" />

   </div>



<script type="text/javascript">
    $(document).ready(function(){
         $('#div-asociar-cuenta').dialog({
            autoOpen: false,
            width:300,
            modal: true
         });
    });
   
    $("#btn-cancelar").click(function(){
        $("#div-asociar-cuenta").dialog('close');
    });



    $("#asociar-account").click(function(){
        
  
        var user =   $("#txt_usuario").val();
        var pwd  =   $("#txt_password").val();

        $.ajax({
                type: "POST",
                url: "<?php echo url_for('@ajax_login_php_practil_associate_account_aceptor_json') ?>",
                data: "token="+calcMD5(pwd)+"&user="+user,
                dataType: 'json',
                success: function(data){
       
                        if(data.token_practil!=null){
                            $("#token_practil").val(data.token_practil);
                            $("#name_practil").val(data.name);
                            $("#last_name").val(data.lastname);
                            $("#email").val(data.email);
                            $("#div-asociar-cuenta").dialog('open');
                        }
                            
                }
        });

    });
    



    $("#btn-asociar-cuenta").click(function(){

    $("#div-botonera").hide();
    $("#div-load-ajax").fadeIn();

    $.ajax({
            type: "POST",
            url: "<?php echo url_for('@asociate_acount') ?>",
            dataType: 'json',
            data: "token_practil="+$("#token_practil").val()+
                  "&name_practil="+$("#name_practil").val()+
                  "&last_name="+$("#last_name").val()+
                  "&email="+$("#email").val()+
                  "&email_associate="+$("#email_associate").val(),
            success: function(data){
                  if(data.success){
                     location.reload();
                  }else{
                     alert(data.message);
                  }
            }
        });


     });



</script>

 <?php endif   ;?>
